<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            var divs=document.getElementsByTagName("div");//集合
            for(var i=0;i<divs.length;i++){
                // divs[i].onclick=function(){
                //     console.log(this.innerHTML);
                // };

                divs[i].addEventListener("click",function(){
                    console.log(this.innerHTML);
                });
            }
        };  
    </script>
</head>
<body>
    <div>div01</div>
    <div>div02</div>
    <div>div03</div>
</body>
</html>